

#import "DoctorApplyController.h"
#import "QcDoctorApplyController.h"
#import "QcInsertViewCell.h"
#import "NetWorkManager.h"
#import "QcDoctorsIfonModel.h"

@interface DoctorApplyController ()<UITableViewDelegate,UITableViewDataSource>

//医生列表界面
@property (nonatomic,strong)NSArray <QcDoctorsIfonModel *>*docModel;

//详细信息界面
@property (nonatomic,strong)NSArray <QcDoctorApplyModel *>*ApplyModel;

//tableView
@property (nonatomic, strong) UITableView *tableview;

//保存label的状态
@property (nonatomic, weak) NSString *state;

@end



static NSString *cellID= @"insertDoctor";
@implementation DoctorApplyController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self getData];
    
    [self setupUI];
    
}

- (void)getData {
    
    //医生列表数据获取
    NSDictionary *dict = @{@"ci1_id":@1,@"ci2_id":@3,@"ci3_id":@3,@"diagnosis_type":@0,@"page_size":@15,@"is_confirmed":@1,@"user_id":@1000089, @"page":@1,@"has_diagnosis":@2};
    
    
    [[NetWorkTool shareManager] POST_RequestWithUrlString:kMatchDoctors parmas:dict successBloock:^(id responseObject) {
        
        NSArray *array = responseObject[@"data"];
       
        self.docModel = [NSArray yy_modelArrayWithClass:[QcDoctorsIfonModel class] json:array];
        

        [self.tableview reloadData];
        
        
    } failureBlock:^(NSError *error) {
        
    }];
    
    //医生详细数据获取
    [[NetWorkTool shareManager] POST_RequestWithUrlString:kMatchDoctors parmas:dict successBloock:^(id responseObject) {
        
        NSArray *array = responseObject[@"data"];
        
        self.ApplyModel = [NSArray
                           yy_modelArrayWithClass:[QcDoctorApplyModel class] json:array];
        
        [self.tableview reloadData];
                
    } failureBlock:^(NSError *error) {
        
    }];
    
    
}

#pragma mark
#pragma mark - 创建界面
- (void)setupUI {
    UITableView *tableView = [[UITableView alloc]init];
    
    self.tableview = tableView;
    
    tableView.delegate = self;
    
    tableView.dataSource = self;
    
    [self.view addSubview:tableView];
    
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.equalTo(self.view);
        
    }];
    
    tableView.rowHeight = 100;
    
    [tableView registerNib:[UINib nibWithNibName:@"QcInsertViewCell" bundle:nil] forCellReuseIdentifier:cellID];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.ApplyModel.count;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    QcInsertViewCell *cell =[tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
    
    QcDoctorsIfonModel *model = self.docModel[indexPath.row];
    
    cell.ifonModel = model;
    
   
    
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_right"]];
    
    cell.accessoryView = imageView;
    
    return cell;
    
}
#pragma mark
#pragma mark - 点击跳转
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    QcDoctorApplyController *vc =[[QcDoctorApplyController alloc]init];
    
    vc.stateBlock = ^(QcDoctorsIfonModel *ifmodel){
        
        [tableView reloadData];
        
    };
    
    QcDoctorApplyModel *model2 = self.ApplyModel[indexPath.row];
    
    vc.model = model2;
    
    QcDoctorsIfonModel *mmodel = self.docModel[indexPath.row];
    
    vc.ifmodel =mmodel;
    
    [self.navigationController pushViewController:vc animated:YES];
    
      [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}


@end
